﻿using System;
using System.Collections.Generic;
using System.Text;
using FrameworkX.ObjectSpace.Data.Providers.SqlServer;
using System.Data.SqlServerCe;

namespace FrameworkX.ObjectSpace.Data.Providers.SqlServerCe
{
    public class SqlCeProvider : IDatabaseProvider
    {
        #region IDatabaseProvider Members

        public ISqlDataTypeTranslator GetDataTypeTranslator()
        {
            return new SqlCeDataTypeTranslator();
        }

        public FrameworkX.ObjectSpace.Data.SqlObjects.Generation.ISqlGenerator GetGenerator()
        {
            return new SqlCeGenerator();
        }

        
        public System.Data.IDbConnection CreateConnection(string connectionString)
        {
            SqlCeConnection conn = new SqlCeConnection(connectionString);
            conn.Open();
            return conn;
        }

        public System.Data.IDbCommand CreateCommand(System.Data.IDbConnection conn)
        {
            SqlCeConnection connection = (SqlCeConnection)conn;
            SqlCeCommand cmd =  new SqlCeCommand();
            cmd.Connection = connection;
            return cmd;
        }

        public System.Data.IDbTransaction CreateTransaction(System.Data.IDbConnection conn)
        {
            throw new NotImplementedException();
        }

        public System.Data.Common.DbParameter CreateParameter()
        {
            return new SqlCeParameter();
        }

        #endregion
    }
}
